package com.xggstudio.crm.ui.mvp.p;

import com.xggstudio.crm.api.APIServer;
import com.xggstudio.crm.api.NetCheckerSubscriber;
import com.xggstudio.crm.base.App;
import com.xggstudio.crm.ui.mvp.m.AssistList;
import com.xggstudio.crm.ui.mvp.v.IMainView;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class P_main {

    private IMainView mainView;

    public P_main(IMainView mainView) {
        this.mainView = mainView;
    }


    public void getAssistList(){
        String token = App.getInstance().getLoginBean().getResult().getAccess_token();

        APIServer.getInstence().getServer()
                .getAssistList(token)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new NetCheckerSubscriber<AssistList>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(AssistList assistList) {
                        if(assistList.getCode().equals("1")){
                            App.getInstance().setAssistList(assistList);
                        }else{

                        }
                    }

                    @Override
                    protected void onNoNetError() {

                    }
                });


    }

}
